<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>

<script type="text/javascript">
	var edit_form_panel = Ext.create("Ext.form.Panel", {
		url : "edit.htm",
		buttonAlign : "center",
		bodyStyle : "padding: 10px;",
		defaultType : "textfield",
		layout : "form",
		items : [
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						fieldLabel : "信用卡卡号",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.card_no",
						xtype : "textfield",
						allowBlank : false
					}, {
						xtype : 'combo',
						minChars : 1,
						fieldLabel : "银行",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.bank_id",
						emptyText : '请选择银行',
						store : comboxStore,
						displayField : 'name',
						valueField : 'kid',
						hiddenlabelStyle : "text-align:right;",labelWidth : 60,
						name : 'card.bank_id',
						typeAhead : true,
						mode : 'remote',
						queryParam : 'srh_name',
						triggerAction : 'all',
						selectOnFocus : true,
						forceSelection : true,
						allowBlank : false
					}, {
						fieldLabel : "开卡日期",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card_date",
						xtype : "datefield",
						format : "Y-m-d",
						allowBlank : false
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						fieldLabel : "信用卡额度",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.money_max",
						xtype : "numberfield",
						allowBlank : false
					}, {
						fieldLabel : "临时额度",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.money_max_temp",
						xtype : "numberfield",
						allowBlank : false
					}, {
						fieldLabel : "超限额度",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.money_max_super",
						xtype : "numberfield",
						allowBlank : false
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						fieldLabel : "附属卡",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.is_other_card",
						xtype : "combo",
						mode : 'local',
						value : '无',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '有', '有' ], [ '无', '无' ] ]
						})
					}, {
						fieldLabel : "逾期情况",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.is_past",
						xtype : "combo",
						mode : 'local',
						value : '无',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '有', '有' ], [ '无', '无' ] ]
						})
					}, {
						fieldLabel : "逾期次数",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.past_cnt",
						xtype : "numberfield"
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [
							{
								fieldLabel : "卡内余额",
								labelStyle : "text-align:right;",labelWidth : 60,
								name : "card.money_remain",
								xtype : "numberfield",
								allowBlank : false
							},
							{
								fieldLabel : "卡种",
								labelStyle : "text-align:right;",labelWidth : 60,
								name : "card.card_type",
								xtype : "combo",
								mode : 'local',
								emptyText : '--请选择--',
								store : new Ext.data.SimpleStore(
										{
											fields : [ 'value', 'text' ],
											data : [ [ '普卡', '普卡' ],
													[ '金卡', '金卡' ],
													[ '白金卡', '白金卡' ],
													[ '钻石卡', '钻石卡' ] ]
										})
							} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						fieldLabel : "还款方式",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.back_type",
						xtype : "combo",
						mode : 'local',
						value : '转账',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '转账', '转账' ], [ '现金', '现金' ] ]
						})
					}, {
						fieldLabel : "有效期",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card_end_date",
						xtype : "datefield",
						format : "Y-m",
						allowBlank : false
					}, {
						fieldLabel : "账单投递方式",
						labelWidth : 75,
						name : "card.bill_type",
						xtype : "combo",
						mode : 'local',
						value : '电子账单',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '电子账单', '电子账单' ], [ '纸质账单', '纸质账单' ] ]
						})
					} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ , {
						fieldLabel : "账单日",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.bill_day",
						xtype : "numberfield",
						allowBlank : false
					}, {
						fieldLabel : "最后还款日",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.bill_back_day",
						xtype : "numberfield",
						allowBlank : false
					} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						fieldLabel : "查询密码",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.pwd_query",
						xtype : "textfield"
					}, {
						fieldLabel : "交易密码",
						labelStyle : "text-align:right;",labelWidth : 60,
						name : "card.pwd_pay",
						xtype : "textfield"
					} ]
				}, {
					fieldLabel : "备注",
					labelStyle : "text-align:right;",labelWidth : 60,
					name : "card.note",
					xtype : "textareafield"
				}, {
					fieldLabel : "id",
					labelStyle : "text-align:right;",labelWidth : 60,
					name : "card.kid",
					hidden : true
				}

		],
		buttons : [ {
			text : "保存",
			formBind : true, //only enabled once the form is valid
			disabled : true,
			handler : function() {
				var form = this.up("form").getForm();
				if (form.isValid()) {
					form.submit({
						waitMsg : "保存中...",
						success : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
							edit_form_panel_win.close();
							dataStore.load();
						},
						failure : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
						}
					});
				}
			}
		} ]
	});

	var edit_form_panel_win = Ext.create("Ext.Window", {
		title : "信用卡编辑",
		closeAction : "hide",
		items : edit_form_panel
	});

	function myEdit(kid) {
		Ext.Ajax.request({
			url : "edit_form.htm?kid=" + kid,
			success : function(response) {
				var json = Ext.util.JSON.decode(response.responseText);
				edit_form_panel.getForm().reset();
				edit_form_panel.getForm().setValues(json);
				edit_form_panel_win.show();
			},
			failure : function(response) {
				Ext.Msg.alert("提示", "操作失败!");
			}
		});
	}//#myEdit
</script>
